package com.magicalcoder.youyamvc.web.controller.admin.logadminoperate;

import com.magicalcoder.youyamvc.app.logadminoperate.service.LogAdminOperateProxyService;
import com.magicalcoder.youyamvc.app.logadminoperate.service.LogAdminOperateService;
import com.magicalcoder.youyamvc.app.model.LogAdminOperate;
import com.magicalcoder.youyamvc.core.common.utils.MapUtil;
import com.magicalcoder.youyamvc.core.spring.admin.AdminLoginController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RequestMapping({"/admin/log_admin_operate_proxy"})
@Controller
public class AdminLogAdminOperateListProxyController extends AdminLoginController
{

    @Resource
    private LogAdminOperateService logAdminOperateService;
    @Resource
    private LogAdminOperateProxyService logAdminOperateProxyService;

    //获取展示列表使用
    @RequestMapping(value = "get_simple_list/save_history/{tableName}")
    public void getSimpleList(@PathVariable String tableName,@PathVariable String operateType,
                              @RequestParam String primaryIdValue,
                    HttpServletRequest request, HttpServletResponse response){
        List<LogAdminOperate> logAdminOperateList = logAdminOperateProxyService.getSimpleList(
                tableName,primaryIdValue);

        toWebSuccessJson(response,logAdminOperateList);
    }

    @RequestMapping(value = "get_item/{id}")
    public void getItem(@PathVariable Long id,
                    HttpServletRequest request, HttpServletResponse response){
        toWebSuccessJson(response,logAdminOperateService.getLogAdminOperate(id));
    }

}
